// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_FIN_MAP_IRA_RO
// * CreateDate    : 2012/2/2 10:17:12
// * Creater       : CodeSmith
// * LastChangeDate: 2012/2/2 10:17:12
// * LastChanger   : 2012/2/2 10:17:12
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Fin
{
/// <summary>
    /// FinMapIraRo
    /// </summary>
    public partial class FinMapIraRoBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objFinMapIraRoEntity">Entity</param>
        /// <returns>Entity</returns>
        public static FinMapIraRoEntity GetFinMapIraRo(FinMapIraRoEntity objFinMapIraRoEntity)
        {
            return DataAccess.SelectSingle<FinMapIraRoEntity>(objFinMapIraRoEntity);
        }
        public static List<FinMapIraRoEntity> GetByApplicationID(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return null;
            }
            FinMapIraRoEntity entity = new FinMapIraRoEntity();
            entity.ApplicationId = id;
            return DataAccess.Select<FinMapIraRoEntity>(entity);
        }
        public static List<FinMapIraRoEntity> GetByReceivedDetailID(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return null;
            }
            FinMapIraRoEntity entity = new FinMapIraRoEntity();
            entity.ReceivedDetailId = id;
            return DataAccess.Select<FinMapIraRoEntity>(entity);
        }
        public static List<SalesDeliveryOrderEntity> GetDeliveryOrderByReceivedDetailID(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return null;
            }
            string sql = @"SELECT SDO.*
                            FROM FIN_RECEIVED_DETAIL RD
                            INNER JOIN FIN_MAP_IRA_RO MAP ON MAP.RECEIVED_DETAIL_ID = RD.RECEIVED_DETAIL_ID
                            INNER JOIN FIN_BILLING_RECEIVED_APPLICATION BRA ON MAP.APPLICATION_ID = BRA.APPLICATION_ID
                            INNER JOIN FIN_MAP_IRA_SDO MAP2 ON MAP2.APPLICATION_ID = BRA.APPLICATION_ID
                            INNER JOIN SALES_DELIVERY_ORDER SDO ON SDO.DELIVERY_ORDER_ID = MAP2.DELIVERY_ORDER_ID
                            WHERE RD.RECEIVED_DETAIL_ID = '" + id + "'";
            return DataAccess.Select<SalesDeliveryOrderEntity>(sql);
        }
        public static List<FinBillingReceivedApplicationEntity> GetBillingAppByReceivedDetailID(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return null;
            }
            string sql = @"SELECT BRA.*
                            FROM FIN_RECEIVED_DETAIL RD
                            INNER JOIN FIN_MAP_IRA_RO MAP ON MAP.RECEIVED_DETAIL_ID = RD.RECEIVED_DETAIL_ID
                            INNER JOIN FIN_BILLING_RECEIVED_APPLICATION BRA ON MAP.APPLICATION_ID = BRA.APPLICATION_ID
                            WHERE RD.RECEIVED_DETAIL_ID = '" + id + "'";
            return DataAccess.Select<FinBillingReceivedApplicationEntity>(sql);
        }
        #endregion

        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objFinMapIraRoEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertFinMapIraRo(FinMapIraRoEntity objFinMapIraRoEntity)
        {
            return DataAccess.Insert(objFinMapIraRoEntity);
        }

        public static bool InsertFinMapIraRo(List<FinMapIraRoEntity> objFinMapIraRoEntityList)
        {
            return DataAccess.Insert(objFinMapIraRoEntityList);
        }
        #endregion

        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objFinMapIraRoEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateFinMapIraRo(FinMapIraRoEntity objFinMapIraRoEntity)
        {
            return DataAccess.Update(objFinMapIraRoEntity);
        }

        public static bool UpdateFinMapIraRo(List<FinMapIraRoEntity> objFinMapIraRoEntityList)
        {
            return DataAccess.Update<FinMapIraRoEntity>(objFinMapIraRoEntityList);
        }
        #endregion

        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objFinMapIraRoEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteFinMapIraRo(FinMapIraRoEntity objFinMapIraRoEntity)
        {
            return DataAccess.Delete(objFinMapIraRoEntity);
        }

        public static bool DeleteFinMapIraRo(List<FinMapIraRoEntity> objFinMapIraRoEntityList)
        {
            return DataAccess.Delete<FinMapIraRoEntity>(objFinMapIraRoEntityList);
        }
        #endregion

        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetFinMapIraRoAll()
        {
            return DataAccess.SelectAllDataSet<FinMapIraRoEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<FinMapIraRoEntity> GetFinMapIraRoAllList()
        {
            return DataAccess.SelectAll<FinMapIraRoEntity>();
        }
        #endregion
	}
	
	
}	

